import os
import subprocess
from optparse import OptionParser
from PIL import Image 

def main(): 
    parser = OptionParser()

    parser.add_option("-i", "--input",
                        dest = "input",
                        help = "input picture files directory",
                        type = "string",
                        action = "store"
                        )
                        
    parser.add_option("-o", "--output",
                        dest = "output",
                        help = "output directory",
                        type = "string",
                        action = "store"
                        )                        
    
    (options, args) = parser.parse_args()

    def bailout():
        parser.print_help()
        raise SystemExit

    if not options.input or not options.output:
        bailout()

    for root, dirs, files in os.walk(options.input):
        for name in files:
            input_fn = options.input + "\\" + name
            resize_fn = options.output + "\\" + name
            print(f"resize_fn = {resize_fn}")
            try:
                img = Image.open(input_fn)
                img = img.resize((1734, 2164))

                img.save(resize_fn)
            except IOError:
                pass

if __name__ == "__main__": 
    main()
